create table p1 (
    product_id int auto_increment not null,
    name varchar(50) not null ,
    quantity_in_stock decimal(5, 2) not null,
    unit_price decimal(5, 2) not null,
    primary key (product_id)
) engine = InnoDb, character set = utf8mb4;

insert into p1
    (name, quantity_in_stock, unit_price)
SELECT
    name, quantity_in_stock, unit_price
from products;

select * from p1;

drop table p1;

-- 2

insert into p1 (
    name, quantity_in_stock, unit_price
)
SELECT
    name, quantity_in_stock, unit_price
from
    products
where
    product_id in (3, 5);
insert into p1 (
    product_id, name, quantity_in_stock, unit_price
)
values (
    5, 'name 5', 17, 9
);

insert into p1 (
    product_id, name, quantity_in_stock, unit_price
)
values (
    3, 'name 3', 17, 9
);

update p1 set
    name = concat(name, '-'),
    quantity_in_stock = 20,
    unit_price = 15,
    product_id = 7
where
    product_id = 3;

select * from p1;

update p1 set
    name = concat(name, '-'),
    quantity_in_stock = 20,
    unit_price = 15
where
    product_id in (2, 5);

select * from p1;

delete from p1 where product_id in (5, 7);

insert into p1
    (name, quantity_in_stock, unit_price)
SELECT
    name, quantity_in_stock, unit_price
from
    products
where product_id > 2;

delete from p1;

delete from p1 where product_id > 0;

select * from p1;
select * from p2

-- transaction
begin;

insert into p1 (name, quantity_in_stock, unit_price) value ('name ttt', 10, 10);

insert into p2 (name, quantity_in_stock, unit_price) value ('name ttt', 10, 10);

-- commit;
-- rollback;

-- 3
select * from p1;
-- drop column
alter table p1 drop name;

-- add column
alter table p1 add column name varchar(50) not null default 'abc';

alter table p1 modify column unit_price decimal(7, 2) not null;

-- alter table p1 modify column name decimal(7, 2) not null default 0;